iobuf support reserve_aligned#2942
Merged
wwbmmm merged 1 commit intoapache:masterfrom Apr 24, 2025
Merged
Conversation
9238244 to
ea60451
Compare
wwbmmm
reviewed
Apr 7, 2025
c0052e4 to
5ece6d7
Compare
chenBright
reviewed
Apr 8, 2025
23b31f7 to
c24eb6f
Compare
chenBright
reviewed
Apr 10, 2025
c24eb6f to
420f36b
Compare
420f36b to
92d262d
Compare
Contributor
Author
|
重构了这个方案,定义了一个IOReserveAlignedBuf结构,这样对IOBuf的影响是最小的,有需求的用户可以使用,IOReserveAlignedBuf内部使用了不同大小的对齐的内存,所以没有放到tls链表里面。目前只实现了一个reserve方法。 |
Contributor
|
释放的内存会放到tls链表? |
Contributor
Author
现在这个实现,释放内存不会放到tls链表。我是担心影响现在的tls链表。 |
Contributor
Author
|
@wwbmmm 再看一下吧 |
yanglimingcn
added a commit
to yanglimingcn/brpc
that referenced
this pull request
May 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
IOBuf通过reserve_aligned(size_t n, size_t alignment)函数在IOBuf内部预分配一些符合对齐规则的内存,后续可以通过unsafe_assign函数或者IOBufAsZeroCopyInputStream等函数把这些内存段解析出来,让用户填充数据。
这样做的好处是,统一使用IOBuf的内存管理机制,典型的如RDMA这种内存需要注册的场景,用户自己去注册会比较麻烦,RDMA已经提供给IOBuf内存分配器,直接使用非常方便。
Issue Number:
#993
Problem Summary:
What is changed and the side effects?
Changed:
Side effects:
Performance effects(性能影响):
Breaking backward compatibility(向后兼容性):
Check List: